home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / MyDesktopDB.p < prev    next >
Encoding:
Text File  |  1996-10-17  |  1.6 KB  |  75 lines  |  [TEXT/CWIE]

  1. unit MyDesktopDB;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Files;
  7.  
  8.     function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
  9. { You can safely ignore the error and use the returned rn in calls to Get/Set, they will just bounce }
  10.     procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  11.     procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  12.  
  13. implementation
  14.  
  15.     uses
  16.         GestaltEqu,
  17.         MyTypes;
  18.         
  19.     function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
  20.         var
  21.             pb: DTPBRec;
  22.             oe: OSErr;
  23.             v: longint;
  24.     begin
  25.         rn := bad_rn;
  26.         oe := Gestalt(gestaltDBAccessMgrAttr, v);
  27.         if (oe = noErr) & not BTST(v, gestaltDBAccessMgrPresent) then begin
  28.             oe := -1;
  29.         end;
  30.         if oe = noErr then begin
  31.             pb.ioNamePtr := nil;
  32.             pb.ioVRefNum := vrn;
  33.             oe := PBDTGetPath(@pb);
  34.             if oe = noErr then begin
  35.                 rn := pb.ioDTRefNum;
  36.             end;
  37.         end;
  38.         GetDesktopDB := oe;
  39.     end;
  40.  
  41.     procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  42.         var
  43.             pb: DTPBRec;
  44.             oe: OSErr;
  45.     begin
  46.         s := '';
  47.         if rn <> bad_rn then begin
  48.             pb.ioNamePtr := @fs.name;
  49.             pb.ioDTRefNum := rn;
  50.             pb.ioDTBuffer := @s[1];
  51.             pb.ioDirID := fs.parID;
  52.             oe := PBDTGetCommentSync(@pb);
  53.             if oe = noErr then begin
  54.                 s[0] := chr(pb.ioDTActCount);
  55.             end else
  56.                 s := '';
  57.         end;
  58.     end;
  59.  
  60.     procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  61.         var
  62.             pb: DTPBRec;
  63.             oe: OSErr;
  64.     begin
  65.         if rn <> bad_rn then begin
  66.             pb.ioNamePtr := @fs.name;
  67.             pb.ioDTRefNum := rn;
  68.             pb.ioDTBuffer := @s[1];
  69.             pb.ioDTReqCount := length(s);
  70.             pb.ioDirID := fs.parID;
  71.             oe := PBDTSetCommentSync(@pb);
  72.         end;
  73.     end;
  74.  
  75. end.